package cn.liangcaomei.eduservice.controller;


import cn.liangcaomei.commonutils.R;
import cn.liangcaomei.eduservice.entity.subject.OneSubject;
import cn.liangcaomei.eduservice.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author LiuJie
 * @since 2024-01-25
 */
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    //添加課程分類,獲取上傳文件，讀取文件
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        //上傳excel文件
        subjectService.saveSubject(file,subjectService);
        return R.ok();
    }

    //查詢課程分類列表方法（樹形）
    @GetMapping("getAllSubject")
    public R getAllSubject(){
        //list集合汎型是一級分類
        List<OneSubject> list = subjectService.getAllOneTwoSubject();
        return R.ok().data("list",list);
    }
}

